package controller;

import jakarta.servlet.ServletException;
import jakarta.servlet.annotation.WebServlet;
import jakarta.servlet.http.HttpServlet;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import model.DTO.DishAddDTO;
import model.DTO.DishDelDOT;
import service.Impl.DishServiceImpl;
import util.GetJsonUtil;
import util.ResultUtil;

import java.io.IOException;

@WebServlet("/admin/dish/add")
public class DishCreateController extends HttpServlet {
    //新增菜品
    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        DishAddDTO da= (DishAddDTO) GetJsonUtil.get(req,new DishAddDTO());
        DishServiceImpl ds=new DishServiceImpl();
        ds.add(da.getCategoryId(),da.getImage(),da.getName(),da.getPrice(),da.getDescription(),da.getId(),da.getStatus());
        String json= ResultUtil.getJSON(null);
        resp.getWriter().println(json);
    }
}
